﻿using Ken_WPF_UI.Data;
using Ken_WPF_UI.Model;
using Ken_WPF_UI.ViewModel;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace Ken_WPF_UI.View
{
    /// <summary>
    /// TreeViewWindow2.xaml 的交互逻辑
    /// </summary>
    public partial class TreeViewWindow2 : Window
    {
        public TreeViewWindow2()
        {
            InitializeComponent();
        }

        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            List<TreeItemModel> lists = TreeData.GetTreeNodeList();
            TreeViewModel treeViewModel = new TreeViewModel();
            treeViewModel.TreeNodeList = lists;
            this.treeView1.DataContext = treeViewModel;
        }

        private void TreeViewItem_Selected(object sender, RoutedEventArgs e)
        {
            TreeViewItem treeViewItem = sender as TreeViewItem;
            MessageBox.Show((treeViewItem.Header  as TreeItemModel).TreeName);
        }
    }

    /// <summary>
    /// 菜单视图模型
    /// </summary>
    public class TreeViewModel
    {
        public List<TreeItemModel> TreeNodeList { get; set; }
    }
}
